package com.park.microprofile.configsource;

import org.eclipse.microprofile.config.spi.ConfigSource;

import java.util.*;

/**
 * 操作系统环境变量配置源
 *
 * @author Aaron
 * @date 2021/7/13 9:55
 */
public class DefaultOperatingSystemEnvSource implements ConfigSource {
    /**
     * 操作系统属性配置
     */
    private final Map<String, String> operatingSystemProperties;

    /**
     * 配置源的优先级
     */
    int ordinal = 300;

    public DefaultOperatingSystemEnvSource() {
        operatingSystemProperties = System.getenv();
    }

    @Override
    public Set<String> getPropertyNames() {
        return Collections.unmodifiableSet(operatingSystemProperties.keySet());
    }

    @Override
    public String getValue(String propertyName) {
        return operatingSystemProperties.get(propertyName);
    }

    @Override
    public String getName() {
        return "Operating System Config Source ";
    }
}
